<?
	class ImageHelper
	{
		static function resize($data, $width, $height)
		{
			$image = imagecreatefromstring($data);
			
			$w = imagesx($image);
			$h = imagesy($image);	
			
			$kw = $width/$w;
			$kh = $height/$h;
			
			$k= $kw > $kh ? $kh : $kw;	
			
			$width  = intval($w*$k);
			$height = intval($h*$k);
			
			$im = imagecreatetruecolor($width, $height);

			imagecopyresampled($im,$image,0,0,0,0,$width,$height,$w,$h);			
			
			ob_start();
			
			imageJPEG($im);
			
			return ob_get_clean();
		}
	}
?>